package games;

import teams.Formation;
import teams.Team;

public class SimpleMatch extends Match {
    // ** Variables **//
    private Formation formation1;

    private Formation formation2;

    private int goals1;

    private int goals2;

    // ** constructores **//
    public SimpleMatch(final Formation formation1, final Formation formation2, final int goles1, final int goles2) {
        this.setTeam1(formation1.getTeam());
        this.setTeam2(formation2.getTeam());
        this.formation1 = formation1;
        this.formation2 = formation2;
        this.goals1 = goles1;
        this.goals2 = goles2;
    }

    // constructor vacio para el hibernate
    protected SimpleMatch() {
    }

    // ** Metodos **//
    @Override
    /**
     * Retorna el Team ganador deduciendolo de la cantidad de goles. 
     */
    public Team getWinner() {
        if (this.goals1 > this.goals2) {
            return this.getTeam1();
        } else if (this.goals1 < this.goals2) {
            return this.getTeam2();
        }
        return null;
    }

    // ** Getters y Setters **//
    public Formation getFormation1() {
        return this.formation1;
    }

    public void setFormation1(final Formation formation1) {
        this.formation1 = formation1;
    }

    public Formation getFormation2() {
        return this.formation2;
    }

    public void setFormation2(final Formation formation2) {
        this.formation2 = formation2;
    }

    public int getGoals1() {
        return this.goals1;
    }

    public void setGoals1(final int goals1) {
        this.goals1 = goals1;
    }

    public int getGoals2() {
        return this.goals2;
    }

    public void setGoals2(final int goals2) {
        this.goals2 = goals2;
    }

}
